/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidade;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author bruno
 */
@Entity
@Table(name = "candidatura")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Candidatura.findAll", query = "SELECT c FROM Candidatura c"),
    @NamedQuery(name = "Candidatura.findByIdCandidatura", query = "SELECT c FROM Candidatura c WHERE c.idCandidatura = :idCandidatura")})
public class Candidatura implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idCandidatura")
    private Integer idCandidatura;
    @JoinColumn(name = "idAreasDisponiveis", referencedColumnName = "idAreasDisponiveis")
    @ManyToOne(optional = false)
    private AreasDisponiveis idAreasDisponiveis;
    @JoinColumn(name = "idCandidato", referencedColumnName = "idCandidato")
    @ManyToOne(optional = false)
    private Candidato idCandidato;
    @OneToMany(mappedBy = "idCandidatura")
    private Collection<Contrato> contratoCollection;

    public Candidatura() {
    }

    public Candidatura(Integer idCandidatura) {
        this.idCandidatura = idCandidatura;
    }

    public Integer getIdCandidatura() {
        return idCandidatura;
    }

    public void setIdCandidatura(Integer idCandidatura) {
        this.idCandidatura = idCandidatura;
    }

    public AreasDisponiveis getIdAreasDisponiveis() {
        return idAreasDisponiveis;
    }

    public void setIdAreasDisponiveis(AreasDisponiveis idAreasDisponiveis) {
        this.idAreasDisponiveis = idAreasDisponiveis;
    }

    public Candidato getIdCandidato() {
        return idCandidato;
    }

    public void setIdCandidato(Candidato idCandidato) {
        this.idCandidato = idCandidato;
    }

    @XmlTransient
    public Collection<Contrato> getContratoCollection() {
        return contratoCollection;
    }

    public void setContratoCollection(Collection<Contrato> contratoCollection) {
        this.contratoCollection = contratoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCandidatura != null ? idCandidatura.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Candidatura)) {
            return false;
        }
        Candidatura other = (Candidatura) object;
        if ((this.idCandidatura == null && other.idCandidatura != null) || (this.idCandidatura != null && !this.idCandidatura.equals(other.idCandidatura))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.Candidatura[ idCandidatura=" + idCandidatura + " ]";
    }
    
}
